package memetic.operators;

import funtions.NGDFitnessFunction;

public class LocalSearchNGD {

	public int[][]neighborhood;
	private NGDFitnessFunction fitnessFunction;
	//Attributes used in the greedy Local Search
	private int i;

	public LocalSearchNGD(NGDFitnessFunction function) {
		super();
		this.fitnessFunction=function;
		this.i=0;
	}
	
	public int[] greedyLocalSearch(int [] individual,int[][]indNeighbor){
		this.neighborhood = indNeighbor;
		int [] bestLocalInd=new int[individual.length];
		bestLocalInd=individual;
		double intialFitFuc=this.fitnessFunction.calculateFitFunct(individual);
		double newFitFuc=0;
		for (this.i = 0; this.i < neighborhood.length; this.i++) {
			newFitFuc=this.fitnessFunction.calculateFitFunct(neighborhood[i]);
			if (newFitFuc>=intialFitFuc) {
				bestLocalInd=neighborhood[i];
			}
		}
		return bestLocalInd;
	}
}
